/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bonc.common.security.controller;

import com.bonc.common.bean.PageContent;
import com.bonc.common.bean.ResultMessage;
import com.bonc.common.security.entity.SysUser;

import com.bonc.common.security.service.*;
import java.util.Map;

import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户登录认证的RestController
 * @author songzongquan
 */
@RestController
@RequestMapping(value = "/api/login")
public class LoginRestController {
    
        
     @Autowired
    private SysUserService sysUserService;


    

    /**
     * @return the sysUserService
     */
    public SysUserService getSysUserService() {
        return sysUserService;
    }

    /**
     * @param sysUserService the sysUserService to set
     */
    public void setSysUserService(SysUserService sysUserService) {
        this.sysUserService = sysUserService;
    }

   

   
    /**
     *  登录
     *
     * @param id
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
    public ResultMessage  login(SysUser sysUser,PageContent pageContent) {
        
        ResultMessage  result = null;
      
        Map  map = getSysUserService().findByCondition(sysUser,pageContent);
        long  total =(Long)map.get("total");
        if ( total >0 ) {
            result = new ResultMessage(true,"登录成功",null);
        } else {
            result = new ResultMessage(false,"用户/口令不对",null);
        }
        

        return result;

    }
   
    
    

    
   
 

    
    
    
}

